package com.util
{
	public class commonLib {
		
	
		public static function sqlFilterling(str:String):String {
			if(str == null ) return '';
			var myPattern0:RegExp = /=/g;
			var myPattern1:RegExp = /%/g;
			var myPattern2:RegExp = /-/g;
			var myPattern3:RegExp = /'/g;
			var myPattern4:RegExp = /'/g;			
			
			if ( str.indexOf("-") != -1 )	{
				str = str.replace(myPattern2, " ");
			}
			if ( str.indexOf("+") != -1 )	{
				str = str.replace("+", "");
			}

			if ( str.indexOf("'") != -1 )	{
				str = str.replace(myPattern3, " ");
			}					
				
			if ( str.indexOf("%") != -1 )	{
				str = str.replace(myPattern1, " ");
			}	
			if ( str.toLocaleLowerCase().indexOf("insert") != -1 )	{
				str = str.replace("insert", "");
			}	
			if ( str.toLocaleLowerCase().indexOf("print") != -1 )	{
				str = str.replace("print", "");
			}	
			if ( str.toLocaleLowerCase().indexOf("set") != -1 )	{
				str = str.replace("set", "");
			}	
			if ( str.toLocaleLowerCase().indexOf("union") != -1 )	{
				str = str.replace("union", "");
			}
			if ( str.toLocaleLowerCase().indexOf("union") != -1 )	{
				str = str.replace("union", "");
			}				
			if ( str.toLocaleLowerCase().indexOf("=") != -1 )	{
				str = str.replace(myPattern0, " ");
			}
		
			if ( str.toLocaleLowerCase().indexOf("or") != -1 )	{
				str = str.replace("or", "");
			}
			
			return str;																	
		}

		public static function sqlReplace(str:String):String {
			
			var myPattern4:RegExp = /˙/g;
			var myPattern5:RegExp = /。/g;
			var myPattern6:RegExp = /、/g;
			var s:String = '\\';
			str = str.replace(myPattern4, "'");
			str = str.replace(myPattern5, s);
			str = str.replace(myPattern6, "\"");			
			
			return str;																	
		}
		
		public static function chgDate(str:String):String {
			
			var val:String = str.substring(0,4)+'-'+str.substring(5,7)+ '-' + str.substring(7,9);			
			
			return val;																	
		}		
		/* 				
 		public static function sqlReplace(val:String):String {
			var returnVal:String;
			var ptDeltags:RegExp;
			var ptDeltag2:RegExp;		// htmltag 제거
			var ptDeltag3:RegExp;		// htmltag 제거
			//var ptDeltag4:RegExp = /'/g;		// htmltag 제거			
	
			ptDeltags = /'/g;
			ptDeltag2 = /\\/g;		
			ptDeltag3 = //g;		
			// '/g;		// htmltag 제거				
 			returnVal 	= val.replace(ptDeltags, '1');		// 작은따옴표
 			//returnVal 	= returnVal.replace(ptDeltag2, '。');		// 작은따옴표
 			//returnVal 	= returnVal.replace(ptDeltag3, '、');		// 작은따옴표 					 								
			return returnVal;
		} */
		 
	}
}

